package cn.com.greatwall.common.model;

import java.util.List;
import java.util.Set;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @Author herw
 * @Time 2022-01-04 09:09:03
 * @Version 1.0
 * @Description: TODO(用一句话描述该文件做什么)
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sys_menu")
public class SysMenu extends SuperEntity {
    private static final long serialVersionUID = 749360940290141180L;

    private String title;
    @TableField(value = "name")
    private String componentName;
    private Integer menuSort = 999;
    private String component;
    private String path;
    private Integer type;
    private String permission;
    private String icon;
    private Boolean cached;
    private Boolean hidden;
    private Long pid;
    private Integer subCount;
    private Boolean iFrame;
    private String url;
    private String html;
    private String css;
    
    /**
     * 请求的类型
     */
    private String pathMethod;

    @TableField(exist = false)
    private List<SysMenu> children;
    @TableField(exist = false)
    private Long roleId;
    @TableField(exist = false)
    private Set<Long> menuIds;
    
    public Boolean getHasChildren() {
        return subCount > 0;
    }
    
    public Boolean getLeaf() {
        return subCount <= 0;
    }

    public String getLabel() {
        return title;
    }
}